<template>
  <div class="app-container">
    <el-card shadow="hover">
      <el-form ref="form" size="mini" :model="listQuery" label-width="100px">
        {{listQuery}}
        <el-row :gutter="10">
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="cgdbh" :label="$t('Statements.cgdbh')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.cgdbh')" v-model="listQuery.cgdbh"/>
            </el-form-item>
          </el-col><!--采购单编号-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="cgdname" :label="$t('Statements.cgdname')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.cgdname')" v-model="listQuery.cgdname"/>
            </el-form-item>
          </el-col><!--采购单名称-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="jszt" :label="$t('Statements.jszt')">
              <el-select v-model="listQuery.jszt" :placeholder="'请选择'+$t('Statements.jszt')">
                <template v-for="(item,index) of dictData.jszt">
                  <el-option :key="item.id" :label="item.dictlabel" :value="item.id"/>
                </template>
              </el-select>
            </el-form-item>
          </el-col><!--结算状态-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="yyname" :label="$t('Statements.yyname')">
              <el-input clearable v-model="listQuery.yyname" :placeholder="'请输入'+$t('Statements.yyname')"/>
            </el-form-item>
          </el-col><!--采购医院名称-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="lsh" :label="$t('Statements.lsh')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.lsh')" v-model="listQuery.lsh"/>
            </el-form-item>
          </el-col><!--药品流水号-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="name" :label="$t('Statements.name')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.name')" v-model="listQuery.name"/>
            </el-form-item>
          </el-col><!--通用名-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="jx" :label="$t('Statements.jx')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.jx')" v-model="listQuery.jx"/>
            </el-form-item>
          </el-col><!--剂型-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="specification"
                          :label="$t('Statements.specification')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.specification')"
                        v-model="listQuery.specification"/>
            </el-form-item>
          </el-col><!--规格-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="unit" :label="$t('Statements.unit')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.unit')" v-model="listQuery.unit"/>
            </el-form-item>
          </el-col><!--单位-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="zhxs" :label="$t('Statements.zhxs')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.zhxs')" v-model="listQuery.zhxs"/>
            </el-form-item>
          </el-col><!--转换系数-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="gysname" :label="$t('Statements.gysname')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.gysname')" v-model="listQuery.gysname"/>
            </el-form-item>
          </el-col><!--生产企业-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="spname" :label="$t('Statements.spname')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.spname')" v-model="listQuery.spname"/>
            </el-form-item>
          </el-col><!--商品名-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="zlcc" :label="$t('Statements.zlcc')">
              <el-select v-model="listQuery.zlcc" :placeholder="'请选择'+$t('Statements.zlcc')">
                <template v-for="(item,index) of dictData.zlcc">
                  <el-option :key="item.id" :label="item.dictlabel" :value="item.id"/>
                </template>
              </el-select>
            </el-form-item>
          </el-col><!--质量层次-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="yptype" :label="$t('Statements.yptype')">
              <el-select v-model="listQuery.yptype" :placeholder="'请选择'+$t('Statements.yptype')">
                <template v-for="(item,index) of dictData.yptype">
                  <el-option :key="item.id" :label="item.dictlabel" :value="item.id"/>
                </template>
              </el-select>
            </el-form-item>
          </el-col><!--药品类别-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="ypph" :label="$t('Statements.ypph')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.ypph')" v-model="listQuery.ypph"/>
            </el-form-item>
          </el-col><!--药品批号-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="rkdh" :label="$t('Statements.rkdh')">
              <el-input clearable :placeholder="'请输入'+$t('Statements.rkdh')" v-model="listQuery.rkdh"/>
            </el-form-item>
          </el-col><!--入库单号-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="qyname" :label="$t('Statements.qyname')">
              <el-select v-model="listQuery.yptype" :placeholder="'请选择'+$t('Statements.qyname')">
                <template v-for="(item,index) of dictData.qyname">
                  <el-option :key="item.id" :label="item.dictlabel" :value="item.id"/>
                </template>
              </el-select>
            </el-form-item>
          </el-col><!--供货商-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item :label="$t('Statements.kscgsj')">
              <el-date-picker
                v-model="listQuery.kscgsj"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col><!--开始采购时间-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item :label="$t('Statements.jecgsj')">
              <el-date-picker
                v-model="listQuery.jecgsj"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col><!--结束采购时间-->
          <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="4">
            <el-form-item prop="rktime"
                          :label="$t('Statements.rktime')">
              <el-date-picker
                v-model="listQuery.rktime"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col><!--入库时间-->
        </el-row>

        <el-row type="flex" justify="center">
          <el-col :xs="12" :sm="9" :md="6" :lg="3" :xl="3">
            <el-button class="pan-btn green-btn" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
                       @click="getList">
              查询
            </el-button>
          </el-col>
          <el-col :xs="12" :sm="9" :md="6" :lg="3" :xl="3">
            <el-button class="pan-btn yellow-btn" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
                       @click="reset">
              清空
            </el-button>
          </el-col>
          <el-col :xs="12" :sm="9" :md="6" :lg="3" :xl="3">
            <el-button :loading="downloadLoading" style="margin-left: 10px;" class="pan-btn blue-btn" type="primary"
                       icon="el-icon-top"
                       @click="handleDownload">
              {{ $t('table.export ') }}
            </el-button>
          </el-col>
        </el-row><!--查询和清空和导出-->
      </el-form>
    </el-card>
    <br/>
    <el-card shadow="hover">
      <el-row type="flex" justify="space-between">
        <el-col :span="3">
          <el-button class="pan-btn green-btn" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
                     @click="handleCreate">
            {{ $t('Statements.adddrugInformation') }}
          </el-button>
        </el-col><!--添加-->
        <el-col t :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-row type="flex" justify="space-between">
            <el-col :push="2">
              <el-button :loading="downloadLoading" class="pan-btn light-blue-btn" type="primary"
                         icon="el-icon-bottom"
                         @click="handleBatchDel">
                {{isMultiple?"取消选择":"保存退货单"}}
              </el-button>
            </el-col><!---->
            <el-col v-if="isMultiple" :push="3">
              <el-button :loading="downloadLoading" class="pan-btn light-blue-btn" type="primary"
                         icon="el-icon-bottom"
                         @click="handleAffirmDel">
                确认保存
              </el-button>
            </el-col><!---->
          </el-row>
        </el-col><!--保存退货量-->
        <el-col :offset="5">
          <pagination style="margin: 0;padding: 0" v-show="pageInfo.total > 0" :total="pageInfo.total"
                      :page.sync="pageInfo.page"
                      :limit.sync="pageInfo.size"
                      @pagination="this.getList"/>
        </el-col><!--分页-->
      </el-row>
      <br/>
      <el-table :data="tableData" v-loading="listLoading" border stripe size="mini" style="width: 100%">

        <el-table-column type="index" width="50"></el-table-column>
        <!--采购单编号-->
        <el-table-column :label="$t('Statements.cgdbh')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.cgdbh }}</span>
          </template>
        </el-table-column>
        <!--采购单名称-->
        <el-table-column :label="$t('Statements.cgdname')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.cgdname }}</span>
          </template>
        </el-table-column>
        <!--流水号-->
        <el-table-column :label="$t('Statements.lsh')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.lsh }}</span>
          </template>
        </el-table-column>
        <!--通用名-->
        <el-table-column :label="$t('Statements.name')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.name }}</span>
          </template>
        </el-table-column>
        <!--商品名-->
        <el-table-column :label="$t('Statements.spname')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.spname }}</span>
          </template>
        </el-table-column>
        <!--交易价-->
        <el-table-column :label="$t('Statements.jyprice')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.jyprice }}</span>
          </template>
        </el-table-column>
        <!--采购量-->
        <el-table-column :label="$t('Statements.cgl')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.cgl }}</span>
          </template>
        </el-table-column>
        <!--采购金额-->
        <el-table-column :label="$t('Statements.rkje')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.rkje }}</span>
          </template>
        </el-table-column>
        <!--入库量-->
        <el-table-column :label="$t('Statements.rkl')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.rkl }}</span>
          </template>
        </el-table-column>
        <!--入库单号-->
        <el-table-column :label="$t('Statements.rkdh')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.rkdh }}</span>
          </template>
        </el-table-column>
        <!--药品批号-->
        <el-table-column :label="$t('Statements.ypph')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.ypph }}</span>
          </template>
        </el-table-column>
        <!--药品有效期-->
        <el-table-column :label="$t('Statements.ypyxsj')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.ypyxsj }}</span>
          </template>
        </el-table-column>
        <!--退货量-->
        <el-table-column :label="$t('Statements.thl')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.thl }}</span>
          </template>
        </el-table-column>
        <!--退货金额-->
        <el-table-column :label="$t('Statements.thje')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.thje }}</span>
          </template>
        </el-table-column>
        <!--退货原因-->
        <el-table-column :label="$t('Statements.thyy')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.thyy }}</span>
          </template>
        </el-table-column>
        <!--结算量-->
        <el-table-column :label="$t('Statements.jsl')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.jsl }}</span>
          </template>
        </el-table-column>
        <!--结算金额-->
        <el-table-column :label="$t('Statements.jsje')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.jsje }}</span>
          </template>
        </el-table-column>
        <!--开始时间-->
        <el-table-column :label="$t('Statements.kscgsj')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.kscgsj }}</span>
          </template>
        </el-table-column>
        <!--结束时间-->
        <el-table-column :label="$t('Statements.jecgsj')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.jecgsj }}</span>
          </template>
        </el-table-column>
        <!--结算状态-->
        <el-table-column :label="$t('Statements.jszt')" align="center">
          <template slot-scope="{row}">
            <span>{{ row.jszt }}</span>
          </template>
        </el-table-column>
        <!--操作-->
        <el-table-column width="150" :label="$t('table.actions')"
                         align="center" class-name="small-padding fixed-width">
          <template slot-scope="{row,$index}">
            <el-button type="primary" class="pan-btn tiffany-btn" size="mini" @click="handleUpdate(row)">
              {{ $t('table.edit') }}
            </el-button>
            <el-button v-if="row.status!='deleted'" class="pan-btn pink-btn" size="mini" type="danger"
                       @click="handleDelete(row,$index)">
              {{ $t('table.delete') }}
            </el-button>
          </template>
        </el-table-column>

      </el-table>
    </el-card>
    <el-dialog :visible.sync="innerVisible" width="400px" title="请选择上级部门">
    </el-dialog>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
      {{temp}}
      <el-row type="flex" :gutter="10">
        <el-form ref="dataForm" :rules="rules" :model="temp" label-position="top">
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.yyid')"
                          prop="yyid">
              <el-input v-model="temp.yyid" disabled/>
            </el-form-item>
          </el-col><!--医院编号-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.yyname')"
                          prop="yyname">
              <el-input v-model="temp.yyname" disabled/>
            </el-form-item>
          </el-col><!--医院名称-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.jsdbh')"
                          prop="jsdbh">
              <el-input v-model="temp.jsdbh" disabled/>
            </el-form-item>
          </el-col><!--结算编号:-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :required="true" :label="$t('Statements.jsdname')"
                          prop="jsdname">
              <el-input v-model="temp.jsdname" disabled/>
            </el-form-item>
          </el-col><!--结算名称:-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.jdtime')"
                          prop="jdtime">
              <el-date-picker type="date" disabled="ture"/>
            </el-form-item>
          </el-col><!--建单时间:-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.contacts')"
                          prop="contacts">
              <el-input v-model="temp.contacts" :placeholder="'请输入'+$t('Statements.contacts')"/>
            </el-form-item>
          </el-col><!--联系人-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.phone')"
                          prop="phone">
              <el-input v-model="temp.phone" :placeholder="'请输入'+$t('Statements.phone')"/>
            </el-form-item>
          </el-col><!--联系电话-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.jszt')"
                          prop="jszt">
              <el-input v-model="temp.jszt" disabled/>
            </el-form-item>
          </el-col><!--结算状态-->
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="18">
            <el-form-item :label="$t('Statements.tjtime')"
                          prop="ypjcbgtime">
              <el-date-picker type="date" disabled="ture"/>
            </el-form-item>
          </el-col><!--提交时间-->
          <el-col :span="24">
            <el-form-item :label="$t('Statements.bz')"
                          prop="bz">
              <el-input clearable
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4}"
                        :placeholder="'请输入'+$t('Statements.bz')"
                        v-model="temp.bz">
              </el-input>
            </el-form-item>
          </el-col><!--备注-->
        </el-form>
      </el-row>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">
          {{ $t('table.cancel') }}
        </el-button>
        <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
          {{ $t('table.saveStatement') }}
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  import {getList, save, update, del} from "@/api/jdgl/ypxxgl"
  import {getDicts} from "@/api/system/dict/data"

  import {parseTime} from '@/utils'

  export default {
    name: "dms-table",
    components: {Pagination},
    data() {
      let diyRule = {
        phoneRule: (rule, value, callback) => {
          let regExp = /^1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/;
          if (regExp.test(value) === false) {
            callback(new Error('电话号码格式不正确'));
          } else {
            callback();
          }
        },
        emailRule: (rule, value, callback) => {
          if (value !== '' && undefined !== value) {
            let regExp = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
            if (regExp.test(value) === false) {
              callback(new Error('邮箱格式不正确'));
            } else {
              callback();
            }
          } else {
            callback();
          }
        }
      }
      return {
        innerVisible: false,
        listLoading: true,
        downloadLoading: false,
        dialogFormVisible: false,
        dialogStatus: '',
        temp: {
          yyid: null,
          yyname: null,
          jsdbh: null,
          jsdname: null,
          jdtime: null,
          contacts: null,
          phone: null,
          tszt: null,
          bz: null
        },
        rules: {
          name: [{required: true, message: '名字不能为空', trigger: 'blur'}],
          contacts: [{required: true, message: '联系人不能为空', trigger: 'blur'}],
          phone: [{required: true, message: '联系电话不能为空', trigger: 'blur'},
            // {validator: diyRule.phoneRule, trigger: 'blur'}
          ],
          //yzbm: [{type: 'number', message: '邮政编码必须为数字值', trigger: "blur"}],
          email: [{validator: diyRule.emailRule, trigger: 'blur'}]
        },
        textMap: {
          update: 'Edit',
          create: '添加采购单'
        },
        pageInfo: {
          total: 1,
          page: 1,
          size: 10,
        },
        tableData: [],
        listQuery: {
          yyname: null,
          thdzt: null,
          cgdbh: null,
          cgdname: null,
          kscgsj: null,
          jecgsj: null,
          lsh: null,
          name: null,
          jx: null,
          specification: null,
          unit: null,
          zhxs: null,
          gysname: null,
          spname: null,
          yptype: null,
          qyname: null,
          rktime: null,
          rkdh: null,
          ypph: null,
          zlcc: null
        },
        dictData: {
          ypjyztType: [],
          yptype: [],
          zlcc: []
        },
        isMultiple: false,
        multipleSelection: [], //table选择的行
      }
    },
    created() {
      this.getList();
      this.initDictData();
    },
    methods: {
      initDictData() {
        getDicts({"dicttype": "ypjyzt_type"}).then(res => {
          this.dictData.ypjyztType = res.data;
          this.temp.ypjyztType = res.data;
        }).catch(err => {
          console.log(err);
        })

        getDicts({"dicttype": "yp_type"}).then(res => {
          this.dictData.yptype = res.data;
          this.temp.ypjyztType = res.data;
        }).catch(err => {
          console.log(err);
        })

        getDicts({"dicttype": "zlcc_type"}).then(res => {
          this.dictData.zlcc = res.data;
          this.temp.ypjyztType = res.data;
        }).catch(err => {
          console.log(err);
        })

      },
      getList() {
        this.listLoading = true;
        getList({...this.pageInfo, ...this.form}).then(res => {
          if (res.code === 10000) {
            this.tableData = res.data.rows;
            this.pageInfo.total = res.data.total;
          }
        }).catch(err => {
          console.log(err);
        }).finally(() => {
          this.listLoading = false;
        })
      },
      reset() {

        this.$refs['form'].resetFields()
      },
      dataFormat: function (row, column, cellValue) {
        if (undefined === cellValue || cellValue === "") {
          return "111";
        }
      },
      resetTemp() {
        this.temp = {
          cgdbh: null,
          cgdname: null,
          cgdzt: null,
          yyname: null,
          auditor: null,
          shtime: null,
          shyj: null,
          ghsj: null,
          contacts: null,
          phone: null,
          bz: null,
        }
      },
      handleCreate() {
        this.resetTemp()
        this.dialogStatus = 'create'
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },
      createData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.temp.author = this.$store.state.user.name;
            save(this.temp).then((res) => {
              this.temp.lsh = res.data;
              this.tableData.unshift(this.temp)
              this.dialogFormVisible = false
              this.$notify({
                title: '成功',
                message: '创建成功',
                type: 'success',
                duration: 2000
              })
            })
          }
        })
      },
      formatJson(filterVal) {
        return this.tableData.map(v => filterVal.map(j => {
          if (j === 'createTime') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        }))
      },
      handleUpdate(row) {
        this.temp = Object.assign({}, row) // copy obj
        this.dialogStatus = 'update'
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },
      updateData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            const tempData = Object.assign({}, this.temp)
            update(tempData).then(() => {
              const index = this.tableData.findIndex(v => v.ypid === this.temp.ypid)
              this.tableData.splice(index, 1, this.temp)
              this.dialogFormVisible = false
              this.$notify({
                title: '成功',
                message: '更新成功',
                type: 'success',
                duration: 2000
              })
            })
          }
        })
      },
      handleDelete(row, index) {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          console.log(row.ypid);
          del(row && row.ypid).then(() => {
            this.tableData.splice(index, 1)
            this.$notify({
              title: '成功',
              message: '删除成功',
              type: 'success',
              duration: 2000
            })
          }).catch(err => {
            console.log(err);
          })
        }).catch(() => {

        });
      },
      handleAffirmDel() {
        if (this.multipleSelection.length !== 0) {
          console.log("执行批量删除");
          setTimeout(() => {
            console.log("执行批量删除完成");
            this.isMultiple = false;
            this.$refs.multipleTable.clearSelection();
          }, 1000)
        } else {
          this.$message({
            message: '请选择一条数据',
            type: 'warning'
          });
        }
      },
      handleBatchDel() {
        this.isMultiple = !this.isMultiple
        if (!this.isMultiple) {
          this.$refs.multipleTable.clearSelection()
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      }
    }
  }
</script>
